package cn.edu.lzzy.mypractices.entity;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.*;
import java.util.Date;
import java.util.List;

@Entity
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class Result extends BaseEntity {
    @Temporal(TemporalType.TIMESTAMP)
    public Date commitTime;
    @ManyToOne
    public User student;
    @ManyToOne
    public Question question;
    @ManyToMany
    public List<Option> options;

    @Transient
    public static final int CORRECT = 0;
    @Transient
    public static final int LES_SELECTION = 1;
    @Transient
    public static final int OVR_SELECTION = 2;
    @Transient
    public static final int MIS_SELECTION = 3;
    @Transient
    public static final int NOT_DONE = 4;


    @JsonBackReference
    public User getStudent() {
        return student;
    }

    @JsonBackReference
    public Question getQuestion() {
        return question;
    }

    @JsonIgnore
    public List<Option> getOptions() {
        return options;
    }
}
